package com.chaos.payment.controller;

import com.chaos.order.api.data.TPayWxConfigData;
import com.chaos.framework.model.dto.ID;
import com.chaos.framework.model.dto.page.PageQueryDto;
import com.chaos.framework.model.dto.result.data.DataResult;
import com.chaos.framework.model.dto.result.list.ListResult;
import com.chaos.framework.model.dto.result.page.PageResult;
import com.chaos.framework.starter.base.BaseController;
import com.chaos.payment.service.TPayWxConfigService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;

/**
*
* @author yjp
* @since 2024-06-18
*/
@Slf4j
@RestController
@Api(tags = "微信支付配置表")
@RequestMapping("/tPayWxCongfig")
public class TPayWxCongfigController extends BaseController<TPayWxConfigData> {
    @Resource
    private TPayWxConfigService tPayWxConfigService;

    @PostMapping("/one")
    @ApiOperation(value = "微信支付配置表详情", httpMethod = "POST")
    public DataResult<TPayWxConfigData> one(@RequestBody ID data){
        return dataResult(tPayWxConfigService.selectByID(data));
    }

    @PostMapping("/list")
    @ApiOperation(value = "微信支付配置表列表", httpMethod = "POST")
    public ListResult<TPayWxConfigData> list(@RequestBody TPayWxConfigData data){
         return listResult(tPayWxConfigService.selectByData(data));
    }

    @PostMapping("/page")
    @ApiOperation(value = "微信支付配置表分页", httpMethod = "POST")
    public PageResult<TPayWxConfigData> page(@RequestBody PageQueryDto<TPayWxConfigData> data){
        return pageResult(tPayWxConfigService.selectByPage(data));
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增微信支付配置表", httpMethod = "POST")
    public DataResult<ID> add(@RequestBody TPayWxConfigData data){
        return dataResult(tPayWxConfigService.insertModel(data));
    }

    @PostMapping("/update")
    @ApiOperation(value = "编辑微信支付配置表", httpMethod = "POST")
    public DataResult<Boolean> update(@RequestBody TPayWxConfigData data){
        return dataResult(tPayWxConfigService.updateModelByID(data));
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除微信支付配置表", httpMethod = "POST")
    public DataResult<Boolean> delete(@RequestBody ID data){
         return dataResult(tPayWxConfigService.deleteModel(data));
    }

}
